package cn.chinaflame.pagodas.web;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import cn.chinaflame.pagodas.Result.Result;
import cn.chinaflame.pagodas.annotation.ApiDoc;
import cn.chinaflame.pagodas.req.PaBalmOrderAddReq;
import cn.chinaflame.pagodas.req.PaOrderAddReq;
import cn.chinaflame.pagodas.service.PaBalmOrderService;

/**
* @author    created by lbq
* @date	     2018年7月24日 上午11:28:13
**/

@RestController
@Transactional(rollbackFor = Exception.class)
@RequestMapping("/openapi/v1/pagodas/balm/")
public class OpenPaBalmOrderAPI {
	  private static Logger log = LoggerFactory.getLogger(OpenPaBalmOrderAPI.class);
	  
	  @Autowired
	  private PaBalmOrderService paBalmOrderService;
	  
	  /**
	     * 下单支付接口接口
	 * @throws Exception 
	     */
	    @PostMapping(value = "add")
	    @ApiDoc(PaOrderAddReq.class)
	    public Object addOrder(@RequestBody PaBalmOrderAddReq req) throws Exception {
	    	req.check();
	        log.info("订单添加接口Req{}:", req);
	        return paBalmOrderService.addOrder(req);
	    }

	    @PostMapping(value = "syjz/add")
		public Object syjzAdd(@RequestBody PaBalmOrderAddReq req) {
			req.check();
			log.info("随缘捐赠订单添加接口Req{}:", req);
			return paBalmOrderService.syjzAdd(req);
		}
	    
	    
	    
	    
	    
		/**
		 * 佛龛香油后台通知
		 * 
		 * @param request
		 * @return
		 */
		@RequestMapping("noticeUrl")
		@ResponseBody
		public String noticeUrl(HttpServletRequest request){
			
			return paBalmOrderService.notifyBkgUrl(request);
		}
	    
	    
	    
	    
	  
}
